import axios from 'axios'
import {URL} from "../config/globalConfig";


const request = axios.create({
    baseURL: URL,
});
// 提交邮寄信息
export const addEntrustInfo = async (options?: { [key: string]: any }): Promise<API.baseResponse<any> | any> => {
    return request({
        method: 'POST',
        url: '/entrusts',
        data: {...(options || {})}
    })
}
// 用户登录
export const userLogin = async (options?: { [key: string]: any }): Promise<API.baseResponse<API.userResponse> | any> => {
    return request({
        method: 'POST',
        url: '/users/login',
        data: {...(options || {})}
    })
}
// 用户注册
export const userRegister = async (options?: { [key: string]: any }): Promise<API.baseResponse<any> | any> => {
    return request({
        method: 'POST',
        url: '/users/register',
        data: {...(options || {})}
    })
}
// 用户登出
export const userLogout = async (options?: { [key: string]: any }): Promise<API.baseResponse<any> | any> => {
    return request({
        method: 'POST',
        url: '/users/logout',
        data: {...(options || {})}
    })
}
// 用户修改信息
export const userUpdateInfo = async (options?: { [key: string]: any }): Promise<API.baseResponse<any> | any> => {
    return request({
        method: 'POST',
        url: '/users/updateInfo',
        data: {...(options || {})}
    })
}
// 获取当前用户权限的匹配邮寄信息
export const getCurUserEntrustInfos = async (options: string): Promise<API.baseResponse<API.entrustResponse[]> | any> => {
    return request({
        method: 'GET',
        url: '/entrusts',
        params: {token: options}
    })
}
// 修改邮寄信息
export const updateEntrustInfo = async (options?: { [key: string]: any }): Promise<API.baseResponse<any> | any> => {
    return request({
        method: 'POST',
        url: '/entrusts/update',
        data: {...(options || {})}
    })
}
// 快递员修改订单状态
export const courierUpdateEntrust = async (options?: { [key: string]: any }): Promise<API.baseResponse<any> | any> => {
    return request({
        method: 'POST',
        url: '/entrusts/courier',
        data: {...(options || {})}
    })
}
// 用户完成的取件
export const userComplete = async (options?: { [key: string]: any }): Promise<API.baseResponse<any> | any> => {
    return request({
        method: 'POST',
        url: '/entrusts/complete',
        data: {...(options || {})}
    })
}